const router = require('koa-router')();
const {
    fetchGoodsList
} = require('../api')
const { tabItems } = require('../data/goodStuffPartitions')

router.get('/goodslist', async (ctx, next) => {
    const channelEnId = ctx.query.channelEnId
    const page = ctx.query.page
    const pushRS = ctx.query.pushRS
    try {
        const data = await fetchGoodsList(page, channelEnId, pushRS)
        ctx.body = data
    } catch(e) {
        next(e)
    }
})

router.get('/goodstabs', (ctx, next) => {
    const resData = {
        code: 0,
        message: "0",
        data: tabItems
    }
    ctx.body = resData
})

module.exports = router.routes()